<template>
	<view>
		<web-view :src="url"></web-view>
	</view>
</template>

<script>
	import {
		BASE_URL
	} from "@/common/config.js"
	export default {
		data() {
			return {
				url: "",
				BASE_URL: BASE_URL
			};
		},
		onLoad() {
			// let open = uni.getStorageSync("kefu_open");
			// if (!open) {
			// 	uni.navigateBack()
			// }

			console.log(this.BASE_URL)
			let server = this.BASE_URL + "/app/index/config"
			let req = {}
			uni.request({
				url: server,
				data: req,
				method: "post",
				header: {
					'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
				},
				success: (res) => {

					// console.log(res)
					if (res.data.data.web_kefu) {
						this.url= res.data.data.web_kefu
						console.log("成功加载客服")
						// uni.setStorageSync("kefu_open", 0)

						// //#ifdef APP-PLUS  
						// plus.runtime.openURL(res.data.data.web_kefu)
						// //#endif 

						// //#ifdef H5
						// window.location.href = res.data.data.web_kefu;
						// //#endif 


					} else {
						uni.showToast({
							icon: "none",
							title: "客服加载失败"
						})
						setTimeout(function() {
							uni.navigateBack()
						}, 1500)

					}


				}
			})
		}
	}
</script>

<style lang="scss">

</style>
